/**
 * @
 * @FilePath     : common_service.h
 * @Version      : 1.0
 * @Description  : 
 * @
 * @Author       : 岳凯(1585202329@qq.com)
 * @Date         : 2025-09-28 17:34:53
 * @
 * @LastEditors  : 岳凯(1585202329@qq.com)
 * @LastEditTime : 2025-10-01 22:02:15
 */
#pragma once

#include "kernel/interfaces/ILogger.h"
#include "kernel/interfaces/IConfiguration.h"
#include "infrastructure/factories/logger_factory.h"
#include <memory>

namespace infrastructure {
namespace services {

/**
 * @brief 通用服务 - 聚合日志工厂和配置服务
 * @details 为其他服务提供统一的基础服务访问点，支持多日志器
 */
class CommonService
{
public:
    explicit CommonService(
        std::shared_ptr<infrastructure::factories::LoggerFactory> loggerFactory,
        std::shared_ptr<kernel::IConfiguration> configService
    );

    virtual ~CommonService() = default;

    /**
     * @brief 获取指定名称的日志服务
     * @param loggerName 日志器名称，如："UserService", "TaskService"
     */
    std::shared_ptr<kernel::ILogger> getLogger(const std::string& loggerName) const;

    /**
     * @brief 获取日志工厂（用于高级操作）
     */
    std::shared_ptr<infrastructure::factories::LoggerFactory> loggerFactory() const { return m_loggerFactory; }

    /**
     * @brief 获取配置服务
     */
    std::shared_ptr<kernel::IConfiguration> configuration() const { return m_configService; }

    /**
     * @brief 检查服务是否已初始化
     */
    bool isReady() const { return m_loggerFactory && m_configService; }

private:
    std::shared_ptr<infrastructure::factories::LoggerFactory> m_loggerFactory;
    std::shared_ptr<kernel::IConfiguration> m_configService;
};

} // namespace services
} // namespace infrastructure